<template>
  <div class="competition-card">
    <div class="competition-item">
      <!-- 左侧图片区域 -->
      <div class="competition-item-left">
        <img :src="item.image || defaultPic" class="competition-pic" alt="比赛图片">
      </div>
      
      <!-- 右侧信息区域 -->
      <div class="competition-item-right">
        <!-- 标题与操作 -->
        <div class="header-actions">
          <div class="competition-name">{{item.name}}</div>
          <el-button type="success" icon="el-icon-arrow-right" @click="GoToDetail">查看详情</el-button>
        </div>
        
        <!-- 信息展示区 -->
        <div class="competition-info-box">
          <div class="info-row">
            <div class="info-label">赛事分类：</div>
            <div class="competition-category">{{ item.category }}</div>
          </div>
          
          <div class="info-row">
            <div class="info-label">主办单位：</div>
            <div class="organizerName">{{ item.organizerName }}</div>
          </div>
          
          <div class="info-row">
            <div class="info-label">开始时间：</div>
            <div class="startTime">{{ item.startTime  | formatDate}}</div>
          </div>
          
          <div class="info-row">
            <div class="info-label">结束时间：</div>
            <div class="endTime">{{ item.endTime  | formatDate}}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  props: {
    item: {
      type: Object,
      default: () => ({})
    },
    sname: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      defaultPic: 'https://img3.doubanio.com/f/movie/8dd0c794499fe925ae2ae89ee30cd225750457b4/pics/movie/celebrity-default-medium.png'
    };
  },
   filters:{
    formatDate(date) {
    return date ? new Date(date).toISOString().replace('T', ' ').substring(0, 19) : null;
  },
  },
  methods: {
    GoToDetail() {
      this.$router.push({
        name: this.sname,
        params: {
          id: this.item.id
        }
      })
    }
  }
};
</script>

<style scoped lang="scss">
$primary-color: #409EFF;
$border-radius: 8px;

.competition-card {
  background: #fff;
  border-radius: $border-radius;
  box-shadow: 0 2px 12px 0 rgba(0,0,0,0.03);
  overflow: hidden;
  transition: all 0.3s ease;
  margin: 10px 0;
  
  &:hover {
    transform: translateY(-5px);
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
  }
}

.competition-item {
  display: flex;
  padding: 20px;
  border: 2px solid #f0f0f0;
  .competition-item-left {
    margin-right: 20px;
//     flex-shrink: 0;
    .competition-pic {
      width: 300px;
      height: 200px;
      display: block;
      border-radius: $border-radius;
      object-fit: cover;
      &:hover {
        transform: scale(1.05);
      }
    }
  }
  
  .competition-item-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    
    .header-actions {
      display: flex;
      justify-content: space-between;
      margin-bottom: 15px;
      
      .competition-name {
        font-size: 20px;
        font-weight: 600;
        color: #333;
        margin-right: 20px;
      }
      
      .el-button {
        padding: 10px 20px;
        font-size: 14px;
      }
    }
    .competition-info-box {
      // display: grid;
      // grid-template-columns: repeat(2, 1fr);
      // gap: 12px 30px;
      .info-row {
        display: flex;
        align-items: center;
        margin-bottom: 10px;
        font-size: 14px;
        color: #666;
      }
      
      .info-label {
        color: #999;
        min-width: 80px;
        font-weight: 500;
      }
    }
  }
}
</style>